﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Http.Headers;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Web.Http.Metadata;

namespace techticx_zone_Webscrapper
{
    public partial class ScrapperMain : Form
    {
        HttpClient hClient=new HttpClient();
        public ScrapperMain()
        {
            InitializeComponent();
        }

        private void url_TextChanged(object sender, EventArgs e)
        {
            
        }
        private bool url_check()
        {
            if (!url.Text.Contains("http://") && !url.Text.Contains("https://"))
            {
                return false;
            }
            else
            {
                hClient.BaseAddress = new Uri(url.Text);
                return true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (url_check())
            {
                MessageBox.Show("Please enter a valid address.");
            }
            else if (selection.Text == "")
            {
                MessageBox.Show("Please select a type to scrape from the website.");
            }
            else if (nameToScrape.Text=="")
            {
                MessageBox.Show("Please enter "+ labelChan.Text +" to search");
            }
            else
            {
                //1) Implementation for url response/validity check
                //2) Start Scrapping the link
                //3) Show Progress in progressDisplay
            }
        }

        private void selection_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show(selection.Text);
            switch (selection.Text)
            {
                case "HTML Tag":
                    labelChan.Text = "Tag";
                    break;
                case "Classes named":
                    labelChan.Text = "Class";
                    break;
                case "ID data":
                    labelChan.Text = "Id";
                    break;
            }
        }
    }
}
